<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
	<head>
		<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
		<meta name="author" content="zhupeng">
		<TITLE>卡片入库</TITLE>
		<script LANGUAGE="javascript" src="../script/common.js"  type="text/javascript"></script>
		<script type="text/javascript" src="../script/print.js"></script>
		<script language="javascript"  type="text/javascript">
			//全局变量
			var org = Common.cOrg();	//当前单位	
			var qt = {};				//数据表格对象
			//页面加载方法
			function load(){ 
				Eui.showNavigation();
				setPages(["listview","amply","printBillDetail"]);
				Common.initDict(searchForm.cardStatus,CardStore.getStoreStatus(),"全 部");	
				Eui.initBeginDateInput("beginDateTd","起始日期","searchForm","beginDate","endDate","_pastDate");
				Eui.initEndDateInput("endDateTd","结束日期","searchForm","beginDate","endDate","date");
				
				createTable();	
			}  
			//生成表格，创建QueryTable对象(查询)
			function createTable(){
				var columns = [];															//复选框
				columns[0] = {render:nameFunc};
				columns[5] = {defOrder:true};																	
			 	columns[7] = {title:"操作",width:"15%" , render:operator,align:"center",order:false}
				searchForm.acquirer.value = org.id; 
				searchForm.status.value = Constants.CARDBILL_STATUS_PASSAGE; 
				qt = new QueryTable("card_in","searchForm","datalist",columns);
			}
			//处理数据 点姓名进入编辑页面
			function nameFunc(v,r){
				return "<a href=# onclick=\"create("+r[7]+");return false;\">"+v+"</a>"
			}
			function operator(v,r){
				var a = " <a href=# onclick=\"cardIn("+r[7]+");return false;\">入库</a>"
				var b = " <a href=# onclick=\"confirmBill("+r[7]+");return false;\">批准</a>"
				var c = " <a href=# onclick=\"rejectBill("+r[7]+");return false;\">拒绝</a>"
				
				if(r[8] == Constants.CARDBILL_STATUS_REQUEST ){
					return b+c;
					
				}else if(r[8] == Constants.CARDBILL_STATUS_PASSED ){
					return  c ;
				}else if(r[8] == Constants.CARDBILL_STATUS_REJECTED){
					return b;
				}else{
					return a ;
				}
				
				
			}
			function confirmBill(id){
				if(!(showQuestion("您确定批准吗?"))){
					return;
				}
				DWR.call("cardStoreService.passDeliveryCardBill",id,function(){
					showInformation("批准成功!");
					qt.showTable();
					
				},{blockScreen:"true"});
			}
			function rejectBill(id){
				var  v = openDialogFrame("/store/add_reject_reason.html?cardBillId="+id,'确认拒绝',200,320)
				if(v){
					qt.showTable();
				}
				
				
			}
	
			//进入明细页面	
			function create(id){
				requestframe.document.location.href = "card_bill_detail.html?cardBillId="+id+"&readOnly=true";
				switchPage("amply");
					
			 }
		    //入库操作
			function cardIn(id){
				if(!(showQuestion("确定入库吗?"))){
					return;
				}
				DWR.call("cardStoreService.confirmWareHousing",id,function(cardBill){
					showInformation("入库成功!")
					switchPage("printBillDetail")
					printBill(cardBill)
				},{blockScreen:"true"});
			}
			function selCardType(){			
				var v = openDialogFrame("/basic/card_type_list.html?",'请选择卡片类型',464,700)
				if (v){
					searchForm.cardType.value = v[1]; 	 
				}
			}
			//较验时间
			function checkDate(){
				if(!checkForm(searchForm))return;
			  	qt.showTable();
			}	
			function onBack(){
				switchPage('listview');
				qt.showTable()
			}
		</script>
	</head>
<body onload="load()">
	<!--页面导航-->
	<div class="nav"><div id="nav">&nbsp;</div></div>
	<!--查询静态页面部分-->
	<div id="listview" >	
		<!--查询条件form-->
		<div class="searchForm">
			<form id="searchForm" name="searchForm">
				<input type="hidden" id="acquirer" name="acquirer" >
				<input type="hidden" id="status" name="status" >
				<table cellSpacing=0 cellPadding=4 width="100%" border=0>
					<tr>
						<td><label>单据编号</label> <input type="text" name="outId" onblur="checkV(this,'number')" maxlength=12></td>
						<td><label>卡片类型</label> <input type="text" name="cardType" ><a class="orga" title="请选择卡片类型" href="javascript:void(0)" onclick="selCardType()">&nbsp;&nbsp;</a></td>								
						<td><label>卡片状态</label> <select name="cardStatus" ><option></option></select></td>
					</tr>
					<tr>
						<td id="beginDateTd">&nbsp;</td>
					    <td id="endDateTd">&nbsp;</td>
					    <td><button type="button" onclick="checkDate()">查 询</button></td>
					</tr>
				</table>
			</form>
		</div>
			<!--查询结构列表-->
			<div id="datalist"></div>	
	</div>		
	<!--明细静态页面部分-->
	<div id="amply" style="display:none;">
		<iframe id="requestframe" name="requestframe" style="width:100%;height:93%;overflow:auto;" frameborder=0 src=""></iframe>
	</div>
	<div id="printBillDetail" class="form" style="display:none;">
		<div class="formTitle">
			<div class="l">单据预览</div>
			<div class="r">
				<button onclick="WebPrint.preview('content')">打印预览</button>
		 		<button onclick="WebPrint.print('content')">打印</button>
		 		<button onclick="onBack()">返回</button>
			</div>
		</div>
		<div  id="content" align='center'></div>
	</div>
</body>
</HTML>
